/*******************************************************************************
 * Copyright (c) 2011 Olexandr V. Shaposhnikov.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Olexandr V. Shaposhnikov - initial API and implementation and/or initial documentation
 *******************************************************************************/
package com.funkyroach.use.core.ast;

import org.eclipse.dltk.ast.ASTVisitor;
import org.eclipse.dltk.ast.declarations.Declaration;
import org.eclipse.dltk.ast.declarations.FieldDeclaration;
import org.eclipse.dltk.ast.references.TypeReference;

public class USVariableDeclaration extends FieldDeclaration {

	private TypeReference type;

	public USVariableDeclaration(USDeclaration decl) {
		super(decl.getName(), decl.getNameStart(), decl.getNameEnd(), decl
				.sourceStart(), decl.sourceEnd());
	}

	@Override
	public int getKind() {
		return Declaration.D_DECLARATOR;
	}

	public void traverse(ASTVisitor visitor) throws Exception {
		if (type != null) {
			visitor.visit(type);
		}

		super.traverse(visitor);
	}

	public void setType(TypeReference type) {
		this.type = type;
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append(" var ");
		sb.append(getName());
		return sb.toString();
	}

}
